<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="集团代码" prop="jtdm">
        <el-input
          v-model="queryParams.jtdm"
          placeholder="请输入集团代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="集团名称" prop="jtmc">
        <el-input
          v-model="queryParams.jtmc"
          placeholder="请输入集团名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="addRow"
          v-hasPermi="['hr:orgManage:add']"
        >添加行</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['hr:orgManage:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['hr:orgManage:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['hr:orgManage:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['hr:orgManage:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table ref="demoTable" highlight-current-row  v-loading="loading" :data="orgManageList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column width="100" label="集团代码" align="center" prop="jtdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="150" label="集团名称" align="center" prop="jtmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="120" label="集团简称" align="center" prop="jtjc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtjc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="集团地址" align="center" prop="jtdz">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtdz">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="集团税号" align="center" prop="jtsh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtsh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="集团开户行" align="center" prop="jtkhx">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtkhx">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="集团账号" align="center" prop="jtzh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtzh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="二级单位代码" align="center" prop="ejdwdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="150" label="二级单位名称" align="center" prop="ejdwmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="二级单位简称" align="center" prop="ejdwjc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwjc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="二级单位地址" align="center" prop="ejdwdz">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwdz">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="二级单位电话" align="center" prop="ejdwdh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwdh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="二级单位税号" align="center" prop="ejdwsh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwsh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="130" label="二级单位开户行" align="center" prop="ejdwkhx">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwkhx">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="二级单位账号" align="center" prop="ejdwzh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.ejdwzh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="三级单位代码" align="center" prop="sjdwdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="三级单位名称" align="center" prop="sjdwmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="三级单位简称" align="center" prop="sjdwjc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwjc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="三级单位地址" align="center" prop="sjdwdz">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwdz">
          </el-input>
        </template>
      </el-table-column>

      <el-table-column width="110" label="三级单位电话" align="center" prop="sjdwdh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwdh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="三级单位税号" align="center" prop="sjdwsh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwsh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="130" label="三级单位开户行" align="center" prop="sjdwkhx">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwkhx">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="三级单位账号" align="center" prop="sjdwzh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.sjdwzh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="部门代码" align="center" prop="bmdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.bmdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="部门名称" align="center" prop="bmmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.bmmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="公司代码" align="center" prop="gcdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gcdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="公司简码" align="center" prop="gcjm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gcjm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="公司名称" align="center" prop="gcmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gcmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="公司地址" align="center" prop="gcdz">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gcdz">
          </el-input>
        </template>
      </el-table-column>

      <el-table-column label="公司电话" align="center" prop="gcdh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gcdh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="公司税号" align="center" prop="gcsh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gcsh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="公司开户行" align="center" prop="gckhx">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gckhx">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="公司账号" align="center" prop="gczh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gczh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="分部代码" align="center" prop="fbdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.fbdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="分部名称" align="center" prop="fbmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.fbmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="分公司代码" align="center" prop="fgcdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.fgcdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="分公司名称" align="center" prop="fgcmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.fgcmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="生产线代码" align="center" prop="scxdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.scxdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="生产线编号" align="center" prop="scxbh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.scxbh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="集团电话" align="center" prop="jtdh">
        <template slot-scope="scope">
          <el-input v-model="scope.row.jtdh">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="生产线编码" align="center" prop="scxbm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.scxbm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="生产线名称" align="center" prop="scxmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.scxmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="分装类型" align="center" prop="fzlx">
        <template slot-scope="scope">
          <el-input v-model="scope.row.fzlx">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="分装线代码" align="center" prop="fzxdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.fzxdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column width="110" label="分装线名称" align="center" prop="fzxmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.fzxmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="班组代码" align="center" prop="bzdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.bzdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="班组名称" align="center" prop="bzmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.bzmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="岗位代码" align="center" prop="gwdm">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gwdm">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="岗位名称" align="center" prop="gwmc">
        <template slot-scope="scope">
          <el-input v-model="scope.row.gwmc">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="包装费用" align="center" prop="bzfy">
        <template slot-scope="scope">
          <el-input v-model="scope.row.bzfy">
          </el-input>
        </template>
      </el-table-column>

      <el-table-column width="110" label="料废损失金额" align="center" prop="lfssje">
        <template slot-scope="scope">
          <el-input v-model="scope.row.lfssje">
          </el-input>
        </template>
      </el-table-column>
      <el-table-column label="合计费用" align="center" prop="hjfy">
        <template slot-scope="scope">
          <el-input v-model="scope.row.hjfy">
          </el-input>
        </template>
      </el-table-column>




      <el-table-column fixed="right" label="操作" width="150" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="bcRow(scope.row)"
            v-hasPermi="['hr:orgManage:edit']"
          >保存</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['hr:orgManage:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改组织机构管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="集团代码" prop="jtdm">
          <el-input v-model="form.jtdm" placeholder="请输入集团代码" />
        </el-form-item>
        <el-form-item label="集团名称" prop="jtmc">
          <el-input v-model="form.jtmc" placeholder="请输入集团名称" />
        </el-form-item>
        <el-form-item label="二级单位简称" prop="ejdwjc">
          <el-input v-model="form.ejdwjc" placeholder="请输入二级单位简称" />
        </el-form-item>
        <el-form-item label="二级单位地址" prop="ejdwdz">
          <el-input v-model="form.ejdwdz" placeholder="请输入二级单位地址" />
        </el-form-item>
        <el-form-item label="二级单位电话" prop="ejdwdh">
          <el-input v-model="form.ejdwdh" placeholder="请输入二级单位电话" />
        </el-form-item>
        <el-form-item label="二级单位税号" prop="ejdwsh">
          <el-input v-model="form.ejdwsh" placeholder="请输入二级单位税号" />
        </el-form-item>
        <el-form-item label="二级单位开户行" prop="ejdwkhx">
          <el-input v-model="form.ejdwkhx" placeholder="请输入二级单位开户行" />
        </el-form-item>
        <el-form-item label="二级单位账号" prop="ejdwzh">
          <el-input v-model="form.ejdwzh" placeholder="请输入二级单位账号" />
        </el-form-item>
        <el-form-item label="三级单位代码" prop="sjdwdm">
          <el-input v-model="form.sjdwdm" placeholder="请输入三级单位代码" />
        </el-form-item>
        <el-form-item label="三级单位名称" prop="sjdwmc">
          <el-input v-model="form.sjdwmc" placeholder="请输入三级单位名称" />
        </el-form-item>
        <el-form-item label="三级单位简称" prop="sjdwjc">
          <el-input v-model="form.sjdwjc" placeholder="请输入三级单位简称" />
        </el-form-item>
        <el-form-item label="三级单位地址" prop="sjdwdz">
          <el-input v-model="form.sjdwdz" placeholder="请输入三级单位地址" />
        </el-form-item>
        <el-form-item label="集团简称" prop="jtjc">
          <el-input v-model="form.jtjc" placeholder="请输入集团简称" />
        </el-form-item>
        <el-form-item label="三级单位电话" prop="sjdwdh">
          <el-input v-model="form.sjdwdh" placeholder="请输入三级单位电话" />
        </el-form-item>
        <el-form-item label="三级单位税号" prop="sjdwsh">
          <el-input v-model="form.sjdwsh" placeholder="请输入三级单位税号" />
        </el-form-item>
        <el-form-item label="三级单位开户行" prop="sjdwkhx">
          <el-input v-model="form.sjdwkhx" placeholder="请输入三级单位开户行" />
        </el-form-item>
        <el-form-item label="三级单位账号" prop="sjdwzh">
          <el-input v-model="form.sjdwzh" placeholder="请输入三级单位账号" />
        </el-form-item>
        <el-form-item label="部门代码" prop="bmdm">
          <el-input v-model="form.bmdm" placeholder="请输入部门代码" />
        </el-form-item>
        <el-form-item label="部门名称" prop="bmmc">
          <el-input v-model="form.bmmc" placeholder="请输入部门名称" />
        </el-form-item>
        <el-form-item label="公司代码" prop="gcdm">
          <el-input v-model="form.gcdm" placeholder="请输入公司代码" />
        </el-form-item>
        <el-form-item label="公司简码" prop="gcjm">
          <el-input v-model="form.gcjm" placeholder="请输入公司简码" />
        </el-form-item>
        <el-form-item label="公司名称" prop="gcmc">
          <el-input v-model="form.gcmc" placeholder="请输入公司名称" />
        </el-form-item>
        <el-form-item label="公司地址" prop="gcdz">
          <el-input v-model="form.gcdz" placeholder="请输入公司地址" />
        </el-form-item>
        <el-form-item label="集团地址" prop="jtdz">
          <el-input v-model="form.jtdz" placeholder="请输入集团地址" />
        </el-form-item>
        <el-form-item label="公司电话" prop="gcdh">
          <el-input v-model="form.gcdh" placeholder="请输入公司电话" />
        </el-form-item>
        <el-form-item label="公司税号" prop="gcsh">
          <el-input v-model="form.gcsh" placeholder="请输入公司税号" />
        </el-form-item>
        <el-form-item label="公司开户行" prop="gckhx">
          <el-input v-model="form.gckhx" placeholder="请输入公司开户行" />
        </el-form-item>
        <el-form-item label="公司账号" prop="gczh">
          <el-input v-model="form.gczh" placeholder="请输入公司账号" />
        </el-form-item>
        <el-form-item label="分部代码" prop="fbdm">
          <el-input v-model="form.fbdm" placeholder="请输入分部代码" />
        </el-form-item>
        <el-form-item label="分部名称" prop="fbmc">
          <el-input v-model="form.fbmc" placeholder="请输入分部名称" />
        </el-form-item>
        <el-form-item label="分公司代码" prop="fgcdm">
          <el-input v-model="form.fgcdm" placeholder="请输入分公司代码" />
        </el-form-item>
        <el-form-item label="分公司名称" prop="fgcmc">
          <el-input v-model="form.fgcmc" placeholder="请输入分公司名称" />
        </el-form-item>
        <el-form-item label="生产线代码" prop="scxdm">
          <el-input v-model="form.scxdm" placeholder="请输入生产线代码" />
        </el-form-item>
        <el-form-item label="生产线编号" prop="scxbh">
          <el-input v-model="form.scxbh" placeholder="请输入生产线编号" />
        </el-form-item>
        <el-form-item label="集团电话" prop="jtdh">
          <el-input v-model="form.jtdh" placeholder="请输入集团电话" />
        </el-form-item>
        <el-form-item label="生产线编码" prop="scxbm">
          <el-input v-model="form.scxbm" placeholder="请输入生产线编码" />
        </el-form-item>
        <el-form-item label="生产线名称" prop="scxmc">
          <el-input v-model="form.scxmc" placeholder="请输入生产线名称" />
        </el-form-item>
        <el-form-item label="分装类型" prop="fzlx">
          <el-input v-model="form.fzlx" placeholder="请输入分装类型" />
        </el-form-item>
        <el-form-item label="分装线代码" prop="fzxdm">
          <el-input v-model="form.fzxdm" placeholder="请输入分装线代码" />
        </el-form-item>
        <el-form-item label="分装线名称" prop="fzxmc">
          <el-input v-model="form.fzxmc" placeholder="请输入分装线名称" />
        </el-form-item>
        <el-form-item label="班组代码" prop="bzdm">
          <el-input v-model="form.bzdm" placeholder="请输入班组代码" />
        </el-form-item>
        <el-form-item label="班组名称" prop="bzmc">
          <el-input v-model="form.bzmc" placeholder="请输入班组名称" />
        </el-form-item>
        <el-form-item label="岗位代码" prop="gwdm">
          <el-input v-model="form.gwdm" placeholder="请输入岗位代码" />
        </el-form-item>
        <el-form-item label="岗位名称" prop="gwmc">
          <el-input v-model="form.gwmc" placeholder="请输入岗位名称" />
        </el-form-item>
        <el-form-item label="包装费用" prop="bzfy">
          <el-input v-model="form.bzfy" placeholder="请输入包装费用" />
        </el-form-item>
        <el-form-item label="集团税号" prop="jtsh">
          <el-input v-model="form.jtsh" placeholder="请输入集团税号" />
        </el-form-item>
        <el-form-item label="料废损失金额" prop="lfssje">
          <el-input v-model="form.lfssje" placeholder="请输入料废损失金额" />
        </el-form-item>
        <el-form-item label="合计费用" prop="hjfy">
          <el-input v-model="form.hjfy" placeholder="请输入合计费用" />
        </el-form-item>
        <el-form-item label="集团开户行" prop="jtkhx">
          <el-input v-model="form.jtkhx" placeholder="请输入集团开户行" />
        </el-form-item>
        <el-form-item label="集团账号" prop="jtzh">
          <el-input v-model="form.jtzh" placeholder="请输入集团账号" />
        </el-form-item>
        <el-form-item label="二级单位代码" prop="ejdwdm">
          <el-input v-model="form.ejdwdm" placeholder="请输入二级单位代码" />
        </el-form-item>
        <el-form-item label="二级单位名称" prop="ejdwmc">
          <el-input v-model="form.ejdwmc" placeholder="请输入二级单位名称" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listOrgManage, getOrgManage, delOrgManage, addOrgManage, updateOrgManage } from "@/api/hr/orgManage";
import {getToken} from "@/utils/auth";

export default {
  name: "OrgManage",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 组织机构管理表格数据
      orgManageList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        jtdm: null,
        jtmc: null,
        ejdwjc: null,
        ejdwdz: null,
        ejdwdh: null,
        ejdwsh: null,
        ejdwkhx: null,
        ejdwzh: null,
        sjdwdm: null,
        sjdwmc: null,
        sjdwjc: null,
        sjdwdz: null,
        jtjc: null,
        sjdwdh: null,
        sjdwsh: null,
        sjdwkhx: null,
        sjdwzh: null,
        bmdm: null,
        bmmc: null,
        gcdm: null,
        gcjm: null,
        gcmc: null,
        gcdz: null,
        jtdz: null,
        gcdh: null,
        gcsh: null,
        gckhx: null,
        gczh: null,
        fbdm: null,
        fbmc: null,
        fgcdm: null,
        fgcmc: null,
        scxdm: null,
        scxbh: null,
        jtdh: null,
        scxbm: null,
        scxmc: null,
        fzlx: null,
        fzxdm: null,
        fzxmc: null,
        bzdm: null,
        bzmc: null,
        gwdm: null,
        gwmc: null,
        bzfy: null,
        jtsh: null,
        lfssje: null,
        hjfy: null,
        jtkhx: null,
        jtzh: null,
        ejdwdm: null,
        ejdwmc: null
      },
      // 表单参数
      form: {},
      upload: {
        // 是否显示弹出层（物料导入）
        open: false,
        // 弹出层标题（物料导入）
        title: "导入数据",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/hr/orgManage/importData"
      },
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询组织机构管理列表 */
    getList() {
      this.loading = true;
      listOrgManage(this.queryParams).then(response => {
        this.orgManageList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    bcRow(row){
      if (row.id != null) {
        updateOrgManage(row).then(response => {
          this.$modal.msgSuccess("修改成功");
          this.open = false;
          this.getList();
        });
      } else {
        addOrgManage(row).then(response => {
          this.$modal.msgSuccess("新增成功");
          this.open = false;
          this.getList();
        });
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        jtdm: null,
        jtmc: null,
        ejdwjc: null,
        ejdwdz: null,
        ejdwdh: null,
        ejdwsh: null,
        ejdwkhx: null,
        ejdwzh: null,
        sjdwdm: null,
        sjdwmc: null,
        sjdwjc: null,
        sjdwdz: null,
        jtjc: null,
        sjdwdh: null,
        sjdwsh: null,
        sjdwkhx: null,
        sjdwzh: null,
        bmdm: null,
        bmmc: null,
        gcdm: null,
        gcjm: null,
        gcmc: null,
        gcdz: null,
        jtdz: null,
        gcdh: null,
        gcsh: null,
        gckhx: null,
        gczh: null,
        fbdm: null,
        fbmc: null,
        fgcdm: null,
        fgcmc: null,
        scxdm: null,
        scxbh: null,
        jtdh: null,
        scxbm: null,
        scxmc: null,
        fzlx: null,
        fzxdm: null,
        fzxmc: null,
        bzdm: null,
        bzmc: null,
        gwdm: null,
        gwmc: null,
        bzfy: null,
        jtsh: null,
        lfssje: null,
        hjfy: null,
        jtkhx: null,
        jtzh: null,
        ejdwdm: null,
        ejdwmc: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加组织机构管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getOrgManage(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改组织机构管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateOrgManage(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrgManage(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除组织机构管理编号为"' + ids + '"的数据项？').then(function() {
        return delOrgManage(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('hr/orgManage/export', {
        ...this.queryParams
      }, `orgManage_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "数据导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('hr/orgManage/importTemplate', {
      }, `组织机构模板.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    addRow(){
      var d = {
        jtdm:'',
        jtmc:''
      };
      this.orgManageList.push(d);
      setTimeout(() => {
        this.$refs.demoTable.setCurrentRow(d);
      }, 10);

      console.log('添加行')
    },
  }
};
</script>
<style lang="scss" scoped>
  ::v-deep .cell .el-input__inner{
    border:none;
  }
</style>

